import {
  DingNotificationErrorEvent,
  DingNotificationGroupEvent,
  DingNotificationPersonalEvent,
  DingNotificationPersonalPointsEvent,
} from '@libs/common/event-emitter';
import { isDev, isPro } from '@libs/common/utils';
import { getConfig } from '@libs/common/utils';
import {
  Inject,
  Injectable,
  OnModuleInit,
  UnauthorizedException,
} from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { Dayjs, FormatDateTime } from '@shencom/utils-date';
import axios from 'axios';
import {
  DWClient,
  DWClientDownStream,
  EventAck,
  RobotMessage,
  TOPIC_CARD,
  TOPIC_ROBOT,
} from 'dingtalk-stream';

import { OvertimeService } from '@/hr/overtime/overtime.service';
import {
  OvertimeApplyStatus,
  times,
} from '@/hr/overtime-apply/entities/overtime-apply.entity';
import { OvertimeApplyService } from '@/hr/overtime-apply/overtime-apply.service';
import { PointsService } from '@/market/points/points.service';
import { PointsHistoryService } from '@/market/points-history/points-history.service';

import { agentId, corpid, miniAppId } from '../config';
import { DepartmentConfigService } from '../department-config/department-config.service';
import { ApiDDCorpConversationMessage, ApiDDRobotSend } from '../dingding.api';
import { DingdingService } from '../dingding.service';
import { MemberService } from '../member/member.service';

const { DD } = getConfig();

const keywords = (m: string) => `${isDev ? 'dev_' : ''}${m}`;

// 计算结束时间
function calculateEndTime(startDate: string, field_1: string) {
  let endDate = '';
  if (field_1 === '1') {
    endDate = FormatDateTime(Dayjs(startDate).add(4, 'hour'));
  } else if (field_1 === '2') {
    endDate = FormatDateTime(Dayjs(startDate).add(9, 'hour'));
  } else if (field_1 === '3') {
    endDate = FormatDateTime(Dayjs(startDate).add(1, 'day').add(4, 'hour'));
  } else if (field_1 === '4') {
    endDate = FormatDateTime(Dayjs(startDate).add(1, 'day').add(9, 'hour'));
  }

  return endDate;
}

interface CallbackOvertimeBase {}

interface CallbackOvertimeApplyParams {
  type: 'overtime';
  value: 'apply';
  description: string;
  day: number;
  startDate: string;
  outTrackId: string;
  userId: string;
}

interface CallbackOvertimeReviewParams {
  type: 'overtime';
  value: 'review';
  id: string;
  userName: string;
  description: string;
  day: string;
  startDate: string;
  endDate: string;
  status: OvertimeApplyStatus;
  remainTimeText: string;
  usedTimeText: string;
  totalTimeText: string;

  outTrackId: string;
  userId: string;
}

interface CallbackOvertimeCancelParams {
  type: 'overtime';
  value: 'cancel';

  outTrackId: string;
  userId: string;
}

enum Keys {
  兑换机积分 = '兑换机积分',
  兑换机积分记录 = '兑换机积分记录',
  工时积分 = '工时积分',
  工时积分申请 = '工时积分申请',
  工时积分申请记录 = '工时积分申请记录',
  上架商品 = '上架商品',
}

@Injectable()
export class RobotService implements OnModuleInit {
  @Inject(DingdingService)
  private readonly dingdingService: DingdingService;
  @Inject(MemberService)
  private readonly memberService: MemberService;
  @Inject(PointsService)
  private readonly pointsService: PointsService;
  @Inject(PointsHistoryService)
  private readonly pointsHistoryService: PointsHistoryService;
  @Inject(DepartmentConfigService)
  private readonly departmentConfigService: DepartmentConfigService;
  @Inject(OvertimeApplyService)
  private readonly overtimeApplyService: OvertimeApplyService;
  @Inject(OvertimeService)
  private readonly overtimeService: OvertimeService;

  private client: DWClient;

  onModuleInit() {
    const client = new DWClient({
      clientId: DD.DD_AppKey,
      clientSecret: DD.DD_AppSecret,
      debug: true,
    });
    this.client = client;
    this.botMessagesGet();
    client.registerAllEventListener((message: DWClientDownStream) => {
      console.log(
        '🚀 ~ RobotService ~ .registerAllEventListener ~ message:',
        message,
      );
      return { status: EventAck.SUCCESS };
    });
  }

  private async overtime_statistics(
    data: RobotMessage & { messageId: string },
  ) {
    const user = await this.overtimeService.findOneById({
      dingId: data.senderStaffId,
    });

    if (!user) {
      await this.helpCustom({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
        content: '联系管理员查BUG，未找到用户~~',
      });
      return;
    }

    this.helpCustom({
      sessionWebhook: data.sessionWebhook,
      messageId: data.messageId,
      content: `你的工时积分\n总计：${user.totalTime}分\n已经使用：${user.usedTime}分\n可用积分：${user.remainTime}分`,
    });
  }

  /** 加班申请卡片 */
  private async overtime_apply(data: RobotMessage & { messageId: string }) {
    const accessToken = await this.dingdingService.getToken();

    // 查询用户的加班时长
    const user = await this.overtimeService.findOneById({
      dingId: data.senderStaffId,
    });

    if (!user) {
      this.helpCustom({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
        content: '联系管理员查BUG，未找到用户~~',
      });
      return;
    }

    const days = times.filter((v) => user.remainTime >= v.time);

    if (!days.length) {
      this.helpCustom({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
        content: `积分不够了，去赞积分吧~。\n你已经使用${user.usedTime}分，可用积分${user.remainTime}分`,
      });
      return;
    }

    await this.dingdingService.Card.overtimeApply(
      {
        senderStaffId: data.senderStaffId,
        robotCode: data.robotCode,
        cardData: { days, status: '0' },
      },
      accessToken,
    );

    this.client.socketCallBackResponse(data.messageId, EventAck.SUCCESS);
  }

  /** 加班申请卡片回调 */
  async callback_overtime_apply(
    params: Omit<CallbackOvertimeApplyParams, 'value' | 'type'>,
  ) {
    console.log('加班申请卡片回调', params);

    if (!params.day) params.day = 0; // 默认为

    const accessToken = await this.dingdingService.getToken();

    if (!params.description || !params.startDate) {
      this.dingdingService.Mi.standardCard(
        {
          senderStaffId: params.userId,
          robotCode: 'dingsqeymayoona1jalx',
          cardData: {
            config: { autoLayout: true, enableForward: true },
            header: {
              title: { type: 'text', text: '出错了~' },
              logo: '@lALPDs6_BfIIWKswQA',
            },
            contents: [
              { type: 'text', text: '数据填写不完整，联系管理员吧！' },
            ],
          },
        },
        accessToken,
      );
      return;
    }

    const day = times[params.day] || times[0];
    const endDate = calculateEndTime(params.startDate, day.field_1);

    const userPrivateData = {
      startDate: FormatDateTime(params.startDate),
      endDate: endDate,
      description: params.description,
      day: day.field_2,
      status: OvertimeApplyStatus['待审核'],
    };

    const user = await this.overtimeService.findOneById({
      dingId: params.userId,
    });

    if (!user) {
      this.dingdingService.Mi.standardCard(
        {
          senderStaffId: params.userId,
          robotCode: 'dingsqeymayoona1jalx',
          cardData: {
            config: { autoLayout: true, enableForward: true },
            header: {
              title: { type: 'text', text: '出错了~' },
              logo: '@lALPDs6_BfIIWKswQA',
            },
            contents: [
              { type: 'text', text: '没有找到你的信息，联系管理员吧！' },
            ],
          },
        },
        accessToken,
      );
      return;
    }

    if (day.time <= 0 || user.remainTime < day.time) {
      this.dingdingService.Card.overtimeApplyUpdate(
        {
          outTrackId: params.outTrackId,
          cardData: {
            startDate: userPrivateData.startDate,
            endDate: userPrivateData.endDate,
            description: '积分不够了，去赞积分吧~。',
            day: userPrivateData.day,
            status: OvertimeApplyStatus['拒绝'],
          },
        },
        accessToken,
      );
      return;
    }

    // 添加申请记录
    const entity = await this.overtimeApplyService.create({
      description: userPrivateData.description,
      startDate: userPrivateData.startDate,
      endDate: userPrivateData.endDate,
      dingId: params.userId,
      outTrackId: params.outTrackId,
      status: userPrivateData.status,
      time: day.time,
    });

    // 发起一个给审核员的审批单
    this.dingdingService.Card.overtimeApplyReview(
      {
        cardData: {
          id: entity.id,
          userName: user.userName,
          startDate: userPrivateData.startDate,
          endDate: userPrivateData.endDate,
          description: userPrivateData.description,
          day: userPrivateData.day,
          totalTimeText: `${user.totalTime}分`,
          remainTimeText: `${user.remainTime}分`,
          usedTimeText: `${user.usedTime}分`,
        },
      },
      accessToken,
    );

    // 更新申请卡片的状态
    this.dingdingService.Card.overtimeApplyUpdate(
      {
        outTrackId: params.outTrackId,
        cardData: {
          startDate: userPrivateData.startDate,
          endDate: userPrivateData.endDate,
          description: userPrivateData.description,
          day: userPrivateData.day,
          status: userPrivateData.status,
        },
      },
      accessToken,
    );
  }

  /** 加班审核卡片回调 */
  async callback_overtime_review(
    params: Omit<CallbackOvertimeReviewParams, 'value' | 'type'>,
  ) {
    // 查用户申请的 outTrackId
    const apply = await this.overtimeApplyService.findById(params.id);

    if (!apply?.outTrackId) {
      throw new Error('申请不存在');
    }

    if (apply.status === OvertimeApplyStatus['取消']) {
      params.status = OvertimeApplyStatus['取消'];
    }

    const accessToken = await this.dingdingService.getToken();

    // 更新审核卡片
    await this.dingdingService.Card.overtimeApplyReviewUpdate(
      {
        outTrackId: params.outTrackId,
        cardData: {
          status: params.status,
          day: params.day,
          description: params.description,
          startDate: params.startDate,
          endDate: params.endDate,
          id: params.id,
          userName: params.userName,
          totalTimeText: params.totalTimeText,
          remainTimeText: params.remainTimeText,
          usedTimeText: params.usedTimeText,
        },
      },
      accessToken,
    );

    // 更新用户申请卡片
    await this.dingdingService.Card.overtimeApplyUpdate(
      {
        outTrackId: apply.outTrackId,
        cardData: {
          status: params.status,
          day: params.day,
          description: params.description,
          startDate: params.startDate,
          endDate: params.endDate,
        },
      },
      accessToken,
    );

    // 同意的情况下直接, 创建钉钉审批单
    if (params.status === OvertimeApplyStatus['通过']) {
      const user = await this.memberService.findOne({
        dingUserId: apply.dingId,
      });
      if (user) {
        const deptId = user.deptIdList.split(',')[0];
        const timeText =
          times.find((v) => apply.time === v.time)?.timeText || '';

        const res = await this.dingdingService.Workflow.workflowOvertime(
          {
            deptId: deptId,
            originatorUserId: user.dingUserId,
            startDate: params.startDate,
            endDate: params.endDate,
            time: timeText,
            description: params.description,
            applyId: apply.id,
          },
          accessToken,
        );

        if (res?.instanceId) {
          await this.overtimeApplyService.update({
            id: params.id,
            instanceId: res.instanceId,
            status: params.status,
            approveTime: FormatDateTime(Dayjs().valueOf()),
          });
        }
      }
    } else {
      // 修改状态
      await this.overtimeApplyService.update({
        id: params.id,
        status: params.status,
        approveTime: FormatDateTime(Dayjs().valueOf()),
      });
    }
  }

  /** 加班申请取消回调 */
  async callback_overtime_cancel(
    params: Omit<CallbackOvertimeCancelParams, 'value' | 'type'>,
  ) {
    const instance = await this.overtimeApplyService.findByOutTrackId(
      params.outTrackId,
    );

    if (!instance) throw new Error('未找到加班申请记录');

    const accessToken = await this.dingdingService.getToken();

    const status = OvertimeApplyStatus['取消'];
    const description = instance.description;
    const startDate = instance.startDate;
    const endDate = instance.endDate;
    const day = times.find((v) => v.time === instance.time)?.field_2 || '0分';

    // 更新加班申请记录状态
    await this.overtimeApplyService.updateStatusByOutTrackId({
      status: status,
      outTrackId: params.outTrackId,
    });

    // 更新加班申请卡片状态
    await this.dingdingService.Card.overtimeApplyUpdate(
      {
        outTrackId: params.outTrackId,
        cardData: {
          startDate: startDate,
          endDate: endDate,
          description: description,
          day: day,
          status: status,
        },
      },
      accessToken,
    );
  }

  /** 加班申请卡片回调 */
  private async callback_overtime(
    params:
      | CallbackOvertimeApplyParams
      | CallbackOvertimeReviewParams
      | CallbackOvertimeCancelParams,
  ) {
    console.log('🚀 ~ params:', params);

    if (params.value === 'apply') {
      return this.callback_overtime_apply({
        userId: params.userId,
        outTrackId: params.outTrackId,
        description: params.description,
        startDate: FormatDateTime(params.startDate),
        day: params.day,
      });
    } else if (params.value === 'cancel') {
      return this.callback_overtime_cancel({
        outTrackId: params.outTrackId,
        userId: params.userId,
      });
    } else if (params.value === 'review') {
      return this.callback_overtime_review({
        id: params.id,
        day: params.day,
        description: params.description,
        endDate: params.endDate,
        startDate: params.startDate,
        userName: params.userName,
        status: params.status,
        remainTimeText: params.remainTimeText,
        totalTimeText: params.totalTimeText,
        usedTimeText: params.usedTimeText,
        outTrackId: params.outTrackId,
        userId: params.userId,
      });
    }
  }

  private async points(data: RobotMessage & { messageId: string }) {
    const user = await this.memberService.findOne({
      dingUserId: data.senderStaffId,
      status: 1,
    });

    if (!user) {
      await this.helpCustom({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
        content: '联系管理员查BUG，未找到用户~~',
      });
      return;
    }

    // 获取用户积分
    const points = (await this.pointsService.findUserPoints(user.userId)) || {
      points: 0,
      frozenPoints: 0,
      historyPoints: 0,
      usedPoints: 0,
    };

    const res = `可用积分: ${points.points}, 冻结积分: ${points.frozenPoints} 历史总积分: ${points.historyPoints} 已使用积分: ${points.usedPoints}`;

    console.log('🚀 ~ RobotService ~ messageKeyword ~ res:', res);

    const record = (await this.pointsHistoryService.findUserPointsHistory(
      { size: 10 },
      user.userId,
    )) || { items: [] };

    const accessToken = await this.dingdingService.getToken();

    await this.dingdingService.Mi.standardCard(
      {
        robotCode: data.robotCode,
        senderStaffId: data.senderStaffId,
        cardData: {
          config: { autoLayout: true, enableForward: true },
          header: {
            title: { type: 'text', text: '你的积分概况' },
            logo: '@lALPDs6_BfIIWKswQA',
          },
          contents: [
            {
              type: 'section',
              fields: {
                shortContent: true,
                list: [
                  { type: 'text', text: `可用积分：${points.points}` },
                  { type: 'text', text: `已使用积分：${points.usedPoints}` },
                  { type: 'text', text: `历史总积分：${points.historyPoints}` },
                ],
              },
            },
            { type: 'text', text: '最近10条积分变动记录' },
            ...record?.items
              .map((v, i) => [
                { type: 'divider' },
                {
                  type: 'section',
                  fields: {
                    shortContent: true,
                    list: [
                      {
                        type: 'markdown',
                        text: `<font size=12>创建时间：${FormatDateTime(
                          v.createdAt,
                        )}</font>`,
                      },
                      {
                        type: 'markdown',
                        text: `<font size=12 color=common_blue1_color>积分：${v.points}</font>`,
                      },
                    ],
                  },
                },
                {
                  type: 'markdown',
                  text: `<font size=12 color=common_level2_base_color>${v.desc}</font>`,
                },
              ])
              .flat(),
          ],
        },
      },
      accessToken,
    );

    this.client.socketCallBackResponse(data.messageId, EventAck.SUCCESS);
  }

  async messageKeyword(data: RobotMessage & { messageId: string }) {
    const content = data?.text.content;
    if (content === keywords(Keys.兑换机积分)) {
      await this.points(data);
    } else if (content === keywords(Keys.兑换机积分记录)) {
      // 10 条积分记录
      await this.helpCustom({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
        content: '还没有开发完成~~',
      });
    } else if (
      content === keywords(Keys.工时积分申请) ||
      content === keywords(Keys.工时积分申请记录) ||
      content === keywords(Keys.工时积分)
    ) {
      const departmentConfig = await this.departmentConfigService.findByUid({
        dingId: data.senderStaffId,
      });

      const existence = departmentConfig.some(
        (v) => v.enableOvertimeAuth === 1,
      );

      if (!existence) {
        await this.help({
          sessionWebhook: data.sessionWebhook,
          messageId: data.messageId,
        });
        return;
      }

      if (content === keywords(Keys.工时积分申请记录)) {
        await this.helpCustom({
          sessionWebhook: data.sessionWebhook,
          messageId: data.messageId,
          content: '还没有开发完成~~',
        });
      } else if (content === keywords(Keys.工时积分申请)) {
        await this.overtime_apply(data);
      } else if (content === keywords(Keys.工时积分)) {
        this.overtime_statistics(data);
      } else {
        await this.helpCustom({
          sessionWebhook: data.sessionWebhook,
          messageId: data.messageId,
          content: '还没有开发完成~~',
        });
      }
    } else {
      await this.help({
        sessionWebhook: data.sessionWebhook,
        messageId: data.messageId,
      });
    }
  }

  async help(options: {
    sessionWebhook: string;
    messageId: string;
    extraKeys?: Keys[];
  }) {
    const { sessionWebhook, messageId, extraKeys = [] } = options;

    const keys = [Keys.兑换机积分, Keys.兑换机积分记录, Keys.上架商品]
      .concat(extraKeys)
      .map((v) => `\n#### **- ${v}**`)
      .join('');

    const body = {
      markdown: {
        title: '帮助文档',
        text: `## 帮助文档 \n### 我不太明白您的问题。您可以试试以下几个问题，给我发送即可：${keys}`,
      },
      msgtype: 'markdown',
    };

    const accessToken = await this.dingdingService.getToken();

    const result = await axios.post(sessionWebhook, body, {
      headers: {
        Authorization: null,
        scid: null,
        'x-acs-dingtalk-access-token': accessToken,
      },
    });

    if (result.status === 200) {
      this.client.socketCallBackResponse(messageId, result.data);
    }
  }

  async helpCustom(options: {
    sessionWebhook: string;
    messageId: string;
    content: string;
  }) {
    const { sessionWebhook, messageId, content } = options;

    const body = { text: { content }, msgtype: 'text' };

    const accessToken = await this.dingdingService.getToken();

    const result = await axios.post(sessionWebhook, body, {
      headers: {
        Authorization: null,
        scid: null,
        'x-acs-dingtalk-access-token': accessToken,
      },
    });

    if (result.status === 200) {
      this.client.socketCallBackResponse(messageId, result.data);
    }
  }

  // 卡片回传请求回调
  async onCardCallback(event: DWClientDownStream) {
    const message = JSON.parse(event.data) as {
      extension: string;
      corpId: string;
      spaceType: string;
      userIdType: number;
      type: string;
      userId: string;
      content: string;
      spaceId: string;
      outTrackId: string;
      value: string;
    };
    const cardPrivateData = JSON.parse(message.content).cardPrivateData;
    console.log('🚀 ~ onCardCallback ~ message:', message);
    console.log('🚀 ~ onCardCallback ~ cardPrivateData:', cardPrivateData);

    const params = cardPrivateData.params as
      | CallbackOvertimeApplyParams
      | CallbackOvertimeReviewParams
      | CallbackOvertimeCancelParams;

    params.outTrackId = message.outTrackId;
    params.userId = message.userId;

    if (params.type === 'overtime') {
      await this.callback_overtime(params);
    }

    this.client.socketCallBackResponse(
      event.headers.messageId,
      EventAck.SUCCESS,
    );
  }

  botMessagesGet() {
    // 机器人消息回调
    // this.client.connected
    this.client
      .registerCallbackListener(TOPIC_CARD, async (res) => {
        console.log('🚀 ~ /v1.0/card/instances/callback ~ res:', res);

        this.onCardCallback(res);
      })
      .registerCallbackListener(TOPIC_ROBOT, async (res) => {
        console.log(
          '🚀 ~ RobotService ~ this.client.registerCallbackListener ~ res:',
          res,
        );
        const { messageId } = res.headers;
        const data = JSON.parse(res.data) as RobotMessage;

        this.messageKeyword({ ...data, messageId });
      })
      .connect();
  }

  /** 消息通知 - 个人兑换通知 */
  @OnEvent(DingNotificationPersonalEvent.key, { async: true })
  async personalMessage(config: DingNotificationPersonalEvent) {
    if (!isPro) return;
    const { userDingId, productName, productNumber, points, pointsHistoryId } =
      config;
    if (!userDingId) return;

    const token = await this.dingdingService.getToken();
    if (!token) throw new UnauthorizedException('dingding token is not exist');

    const date = FormatDateTime(Dayjs().valueOf());

    const context = {
      msgtype: 'action_card',
      action_card: {
        title: '兑换通知',
        markdown: `### 兑换通知\n#### 商品：${productName} * ${productNumber}\n#### 积分：${points}\n#### 时间：${date}`,
        single_title: '查看详情',
        single_url: `dingtalk://dingtalkclient/action/open_micro_app?corpid=${corpid}&miniAppId=${miniAppId}&agentId=${agentId}&pVersion=1&packageType=1&page=pages%2Fmarket%2Frecord-detail%3Fid%3D${pointsHistoryId}`,
      },
    };

    const res = await ApiDDCorpConversationMessage({
      access_token: token,
      userDingId,
      context,
    });

    return res;
  }

  /** 消息通知 - 个人添加积分通知 */
  @OnEvent(DingNotificationPersonalPointsEvent.key, { async: true })
  async personalAddPointsMessage(config: DingNotificationPersonalPointsEvent) {
    if (!isPro) return;
    const { userDingId, points, addPoints, pointsHistoryId, desc } = config;
    if (!userDingId) return;

    const token = await this.dingdingService.getToken();
    if (!token) throw new UnauthorizedException('dingding token is not exist');

    const date = FormatDateTime(Dayjs().valueOf());

    const context = {
      msgtype: 'action_card',
      action_card: {
        title: '积分变动通知',
        markdown: `### 积分变动通知\n#### 积分：+${addPoints}\n#### 说明：${desc} \n#### 现存：${points}\n#### 时间：${date}`,
        single_title: '查看详情',
        single_url: `dingtalk://dingtalkclient/action/open_micro_app?corpid=${corpid}&miniAppId=${miniAppId}&agentId=${agentId}&pVersion=1&packageType=1&page=pages%2Fmarket%2Frecord-detail%3Fid%3D${pointsHistoryId}`,
      },
    };

    const res = await ApiDDCorpConversationMessage({
      access_token: token,
      userDingId,
      context,
    });

    return res;
  }

  /** 自定义机器人 - 兑换通知 */
  @OnEvent(DingNotificationGroupEvent.key, { async: true })
  async groupMessage(config: DingNotificationGroupEvent) {
    if (!isPro) return;
    const { userName, productName, productNumber, points, result, orderNo } =
      config;

    const date = FormatDateTime(Dayjs().valueOf());

    const context = {
      msgtype: 'markdown',
      markdown: {
        title: '兑换通知',
        text: `### 兑换通知 - ${userName}\n#### 订单：${orderNo}\n#### 商品：${productName} * ${productNumber}\n#### 总价：${points}\n#### 状态：${result}\n#### 时间：${date}
        `,
      },
    };

    ApiDDRobotSend({
      access_token:
        'c1c8c49225b6448fffcbf0ac30c13ea41aaedc7a9d9fd0e3850fdba81e95f62e',
      context,
    });
  }

  /** 自定义机器人 - 异常通知 */
  @OnEvent(DingNotificationErrorEvent.key, { async: true })
  async errorCreate(config: DingNotificationErrorEvent) {
    if (!isPro) return;
    const { name, message } = config;
    const context = {
      msgtype: 'markdown',
      markdown: {
        title: `异常通知 - ${name}`,
        text: `${message} \n #### 时间：${FormatDateTime(Dayjs().valueOf())}`,
      },
    };
    ApiDDRobotSend({
      access_token:
        'cc384eef39bbecefce5b91054fe1f1f0cd23b4af65420f50334fd605cd6215b0',
      context,
    });
  }

  /** 自定义机器人 - 工时查询 */
}
